<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS边框特效</title>
<style type="text/css">
.aa{
  position: relative;
  width: 200px;
  height: 200px;
  margin: 30px auto;
  text-align: center;
  line-height: 200px;
  background-color: #6cf;
}
.aa:before, .aa:after{
  content: '';
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  position: absolute;
  transition: transform .35s;
}
.aa:before{
  transform: scale(1, 0);
}
.aa:after{
  transform: scale(0, 1);
}
.aa:hover:before{
  border-left: 1px solid #000;
  border-right: 1px solid #000;
  transform: scale(1);
}
.aa:hover:after{
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  transform: scale(1);
}

.bb {
  position: relative;
  width: 200px;
  height: 200px;
  margin: auto;
  background: no-repeat 50%/70% rgba(0, 0, 0, 0.1);
  color: #69ca62;
  box-shadow: inset 0 0 0 1px rgba(105, 202, 98, 0.5);
}
.bb:before, .bb:after {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}
.bb:before, .bb:after {
    content: '';
    z-index: -1;
    margin: -5%;
    box-shadow: inset 0 0 0 2px;
    animation: clipMe 6s linear infinite;
}

.bb:before {
    animation-delay: -3s;
}

@keyframes clipMe {
    0%, 100% {
        clip: rect(0px, 220px, 2px, 0px);
    }
    25% {
        clip: rect(0px, 2px, 220px, 0px);
    }
    50% {
        clip: rect(218px, 220px, 220px, 0px);
    }
    75% {
        clip: rect(0px, 220px, 220px, 218px);
    }
}
</style>
</head>
<body>
  <div class="aa">移到这里</div>
  <div class="bb"></div>
</body>
</html>